#include "StdAfx.h"
#include "ActorManager.h"
#include "ActorMultiIndexIterator.h"
namespace _MODULE_
{
	namespace _GAME_
	{
		ActorManager::ActorManager(void):
			m_miindexActorByUniq(m_misetActor.get<_M_GAME::UniqName>()),
			m_miindexActorByType(m_misetActor.get<_M_GAME::TypeName>()),
			m_miindexActorByTag(m_misetActor.get<_M_GAME::TagName>())
		{
		}

		ActorManager::~ActorManager(void)
		{
		}

		void ActorManager::AddActor(_P_GAME::Actor* ptrActor)
		{
			assert(ptrActor&&__T("ActorManager::AddActor_ptrActo is NULL!!!"));
			m_misetActor.insert(ptrActor);
		}
		void ActorManager::RemoveActor(_P_GAME::Actor* ptrActor)
		{
			assert(ptrActor&&__T("ActorManager::RemoveActor_ptrActo is NULL!!!"));
			m_misetActor.erase(ptrActor->GetUniqName());
		}

	
		const _P_GAME::Actor* ActorManager::FindActorByUniqName(const _FO_UTIL::Name& nameUniq)
		{
			
			Actor_MISet_By_Uniq::iterator it;
			it=m_miindexActorByUniq.find(nameUniq);

			
			if(it!=m_miindexActorByUniq.end())
			{
				return *it;
			}
			else
			{
				return NULL;
			}
		}

		iCommonActorIterate* ActorManager::GetActorGroupByType(const _FO_UTIL::Name& nameType)
		{
			Actor_MISet_By_Type::iterator iter;
			iter=m_miindexActorByType.find(nameType);

			if(iter!=m_miindexActorByType.end())
			{//found
				Actor_MISet_Type_Iter* ptrNewIter=foNEW Actor_MISet_Type_Iter(&m_miindexActorByType);

				
				ptrNewIter->Set(iter);

				return ptrNewIter;
			}
			else
				return NULL;
		}
		iCommonActorIterate* ActorManager::GetActorGroupByTag(const _FO_UTIL::Name& nameTag)
		{

			Actor_MISet_By_Tag::iterator iter;
			iter=m_miindexActorByTag.find(nameTag);

			if(iter!=m_miindexActorByTag.end())
			{//found
				Actor_MISet_Tag_Iter* ptrNewIter=foNEW Actor_MISet_Tag_Iter(&m_miindexActorByTag);

				ptrNewIter->Set(iter);

				return ptrNewIter;
			}
			else
				return NULL;

		}
		iCommonActorIterate* ActorManager::GetActorGroup()
		{
			Actor_MISet_Uniq_Iter* ptrNewIter=foNEW Actor_MISet_Uniq_Iter(&m_miindexActorByUniq);

			return ptrNewIter;
		}


		
	}
}